package com.sunchangming.stmdb.xgen;

@Deprecated
public class TypeBinary {

	public String getName(Variable variable) {
		return "byte[]";
	}

	public String getMarshalStr(Variable v, String osname) {
		return String.format("if(%s!=null) %s.write(%s,0,%s.length)", v.getName(), osname, v.getName(), v.getName());
	}

	public String getUnmarshalStr(Variable v, String osname, boolean useThis) {
		final StringBuilder sb = new StringBuilder();
		sb.append(v.getName()).append("=new byte[").append(osname).append(".available()];\n");
		sb.append(osname).append(".readFully(").append(v.getName()).append(");");
		return sb.toString();
	}

	public String getBoxName() {
		throw new RuntimeException("wrong");
	}

	public String getDefaultValue(Variable variable) {
		return "null";
	}

	public String getHashCodeStr(Variable variable) {
		return "java.util.Arrays.hashCode(this." + variable.getName() + ")";
	}

	public String getTestEqualsStr(Variable variable, String string) {
		return "java.util.Arrays.equals(this." + variable.getName() + ", " + string + "." + variable.getName() + ")";
	}

}
